package hot_100;

public class 矩阵置零 {
    public static void main(String[] args) {

    }

    public void setZeroes(int[][] matrix) {
        int n = matrix.length;
        int m = matrix[0].length;
        int[] x = new int[n];
        int[] y = new int[m];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (matrix[i][j] == 0) {
                    x[i] = y[j] = 0;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (x[i] == 0 || y[j] == 0) {
                    matrix[i][j] = 0;
                }
            }
        }
    }
}
